<template>
	<view class="course-container">
		<u-navbar bgColor="#1A1A1A" autoBack height="90" placeholder fixed>
		</u-navbar>
		<!-- 标题 -->
		<view class="course-title">
			<image src="../../static/imgs/my-like.png"></image>
			<text>我收藏的课程</text>
		</view>
		<view class="course-list">
			<view class="list-title">{{total}}节课程</view>
			<view class="list-content" v-for="item in course" :key="item.id" @click="toDetail(item.id)">
				<view class="content-img">
					<image src="../../static/imgs/course1.png" mode=""></image>
				</view>
				<view class="content-desc">
					<view class="desc-title">{{item.name}}</view>
					<view class="desc-info">{{item.level===1?"零基础":"高强度"}}.{{item.totalTime}}分钟</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {courese} from "@/api/my.js"
	export default { 
		data() {
			return {
				courseInfo:{},
				userId:"",
				total:"",
				course:[]
			};
		},
		methods:{
			getCourse(){
				courese({
					id:this.userId
				}).then(res=>{
					this.total=res.data.length
					this.course=res.data
				})
			},
			toDetail(id){
				uni.navigateTo({
					url:'./courseDetail?id='+id
				})
			}
		},
		onShow() {
			this.userId=uni.getStorageSync("userId")
			this.getCourse()
		}
	}
</script>

<style lang="scss" scoped>
	.course-container{
		height: 100%;
		overflow-y: auto;
		.course-title{
			display: flex;
			align-items: center;
			padding:0rpx 50rpx 40rpx 50rpx;
			background-color: #1A1A1A;
			image{
				width: 198rpx;
				height: 167rpx;
				margin-right: 40rpx;
			}
			text{
				font-size: 36rpx;
			}
		}
		.course-list{
			height: calc(100% - 192px);
			background-color: #000000;
			padding: 70rpx 53rpx;
			.list-title{
				font-size: 30rpx;
				color: #929292;
			}
			.list-content{
				display: flex;
				margin-top: 40rpx;
				image{
					width: 305rpx;
					height: 188rpx;
					margin-right: 40rpx;
				}
				.content-desc{
					.desc-info{
						font-size: 24rpx;
						color: #717171;
					}
				}
			}
		}
	}
</style>
